package com.qf.fengmimall.product.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qf.fengmimall.product.entity.Product;
import com.qf.fengmimall.product.mapper.ProductMapper;
import com.qf.fengmimall.product.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Comparator;
import java.util.List;

/**
 * <p>
 * 商品 商品信息相关表：分类表，商品图片表，商品规格表，商品参数表 服务实现类
 * </p>
 *
 * @author lx
 * @since 2023-02-14
 */
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductService {

    @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
    @Autowired
    private ProductMapper productMapper;

    /**
     * 新品推荐
     *
     * @return
     */
    @Override
    public List<Product> getCategoryreCommends() {
        List<Product> productList = productMapper.getProductImgs();
        productList.sort(Comparator.comparing(Product::getCreateTime).reversed());
        return productList.subList(0, 3);
    }

}
